package com.xmy.study.util;

import java.util.Comparator;

class WeekdayComparator implements Comparator<String> {
    @Override
    public int compare(String o1, String o2) {
        // 定义星期的顺序，按照从周一到周日的顺序进行排序
        String[] weekdays = {"星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"};

        int index1 = -1;
        int index2 = -1;

        for (int i = 0; i < weekdays.length; i++) {
            if (o1.equals(weekdays[i])) {
                index1 = i;
            }
            if (o2.equals(weekdays[i])) {
                index2 = i;
            }
        }

        return Integer.compare(index1, index2);
    }
}
